Conversation
Go back to using master branch in scanner
583e8ee to
0417a44
Compare
No, it does not exists (I tested it). And, as I showed before, MakeBoxes does not use that information to build a Boxed expression. It happens afterwards (when Boxes are converted into text strings)
Also, this does not happen in WMA. Otherwise, it would come up in my tests. In some way, |
mathics/builtin/atomic/strings.py
Outdated
| # runs ToString[] on the resulting M-expression. | ||
| session = MathicsSession() | ||
| try: | ||
| expr = parse(session.definitions, MathicsSingleLineFeeder(expr.value)) |
There was a problem hiding this comment.
really do you want to create a session to convert a string?
There was a problem hiding this comment.
Yes, I suppose it is better to just Definitions. I am not sure though if we want add_builtin set True or False. You tell me.
The thought here was to use a clean slate of the definitions, and not modification made to the built-in functions.
But you tell me, does ToString behavior of an expression change if there has been an altered behavior to built-in function functions or other functions added which appear in the string part of ToString?
There was a problem hiding this comment.
MakeBoxes does not use that information to build a Boxed expression.
I wasn't intending to imply that. Instead, there is ToString that accepts an encoding parameter. In the course of doing, ToString calls boxes_to_text() which triggers MakeBoxes .
Right now MakeBoxes performs formatting of operators before it returns. We need to get the information through to the formatter that MakeBoxes is invoking . In a functional approach which is what would be preferred here, this would passed via the function call arguments somehow.
It happens afterwards (when Boxes are converted into text strings)
Currently in Mathics, Boxing and Formatting can be interleaved. So right now there is no absolute "afterwards".
In Wolfram Alpha are there ever situations where Boxing and Formatting are interleaved?
Removing this interleaving in Mathics would require a major refactoring of our code. If that needs to be done, I think we need to reduce our goals for the time being and set a more easily-achievable bar to reach.
that apparently is all we need.
|
In order to dig deeper into |
This is a little closer to the correct behavior when
ToString[]is passed a string argument.We currently can't handle passing an "encoding" parameter to
ToString[], for example:The main obstacle here is understanding how go get the desired encoding passed down via the direct call to
MakeBoxesdown to formatting where this should be used.WMA does not explicitly list
CharacterEncodingas an option toMakeBoxes. Does it exist and is not documented? Assuming it does not exist, how would WMA pass this information down?However it is done, in our current code base, we do not have such a feature, short of changing
$CharacterEncodingwhich we should avoid doing.